package de.tabuma.customer.view;

import de.tabuma.customer.*;
import de.tabuma.customer.entity.*;
import de.tabuma.lib.tabumaview;
import java.io.PrintWriter;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author alefen
 */
public class removeView extends tabumaview {

    public removeView(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {

        String removeContent = "Do you really want to remove {1}?";
        String back = "back";
        String remove = "remove";
        Customer customer = (Customer) request.getAttribute(constants.paramCustomer);

        out.println("<form action=\""+this.getServlet()+"\">");
        out.println("<div class=\"contentContent\">");
        out.println(removeContent.replaceAll("\\{1\\}", customer.getName()));
        out.println("</div>");
        out.println("<div class=\"contentContent\">");
        Enumeration enu = this.getParameter().keys();
        while(enu.hasMoreElements()) {
            String key = (String) enu.nextElement();
            String value = request.getParameter(key);
            out.println("<input type=\"hidden\" name=\""+key+"\" value=\""+value+"\"/>\n");
        }
        out.println("<input type=\"hidden\" name=\""+constants.paramName+"\" value=\""+constants.ACTION_REMOVE+"\"/>");
        out.println("<input type=\"hidden\" name=\""+constants.paramRemove+"\" value=\"true\"/>");
        out.println("<input type=\"hidden\" name=\""+constants.paramId+"\" value=\""+customer.getId()+"\"/>");
        out.println("<input type=\"submit\" class=\"button\" value=\""+remove+"\"/>");
        out.println("<input type=\"button\" class=\"button\" value=\""+back+"\" onClick=\"javascript:history.back()\"/>");
        out.println("</div>");
        out.println("</form>");

    }
    
}
